//书写品牌管理模块接口
import request from '@/utils/request'
import type { TColumnTypeListResponseData, TColumnType } from './type'
enum API {
  URL_COLUMNTYPE_LIST = '/v1/m/dic/columnType/allColumnTypes',

  URL_COLUMNTYP_ADD = '/v1/m/dic/columnType',
  URL_COLUMNTYP_UPDATE = '/v1/m/dic/columnType/',

  URL_COLUMNTYP_DELETE = '/v1/m/dic/columnType/',
}

export const reqColumnTypeList = (
  pageNum: number,
  pageSize: number,
  columnTitle: string,
) =>
  request.get<any, TColumnTypeListResponseData>(
    API.URL_COLUMNTYPE_LIST +
      `?page=${pageNum}&limit=${pageSize}&columnTitle=${columnTitle}`,
  )
// //添加与修改已有品牌接口方法
export const reqAddOrUpdateColumnType = (data: TColumnType) => {
  if (data.typeId) {
    return request.put<any, any>(API.URL_COLUMNTYP_UPDATE + data.typeId, data)
  } else {
    return request.post<any, any>(API.URL_COLUMNTYP_ADD, data)
  }
}

// //删除某一个已有品牌的数据
export const reqDeleteColumnType = (id: number) =>
  request.delete<any, any>(API.URL_COLUMNTYP_DELETE + id)
